var t = require;
var e = module;
var o = exports;
var a,
    i =
    (this && this.__extends) ||
    ((a = function(t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({ __proto__: [] }
                    instanceof Array &&
                    function(t, e) {
                        t.__proto__ = e;
                    }) ||
                function(t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function(t, e) {
            a(t, e);

            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        });
Object.defineProperty(o, "__esModule", { value: !0 });
var n = t("BaseManager"),
    r = t("GameEm"),
    s = t("GameCof"),
    c = (function(t) {
        i(e, t);

        function e(e, o) {
            void 0 === o && (o = !1);
            var a = t.call(this, e, o) || this;
            a.map1 = !1;
            a.shopBuy = {};
            a.isBuyData = {};
            a.mulAdAddPro = 1;
            a.mulAd2AddPro = 1;
            a.mulAd3AddPro = 1;
            a.mulAd2Time = 0;
            a.mulAd3Time = 0;
            a.monthlyCardTime = 0;
            a.weekCardTime = 0;
            a.lastMonthTime = "";
            a.lastWeekTime = "";
            a.isMonthlyCard = !1;
            a.isWeekCard = !1;
            a.payAddZs = 0;
            a.monthObj = {};
            a.weekObj = {};
            a.allKey = {};
            a.xfjl = [];
            a.dayString = "";
            if (o) {
                a.loadData();
                a.init();
            }
            return a;
        }
        e.prototype.init = function() {};
        return e;
    })(n.ArchiveBase),
    p = new((function() {
        function t() {
            this.psw = {
                aa: "shopBuy",
                ab: "isBuyData",
                ac: "mulAdAddPro",
                ad: "mulAd2AddPro",
                ae: "mulAd3AddPro",
                af: "mulAd2Time",
                ag: "mulAd3Time",
                ah: "monthlyCardTime",
                ai: "weekCardTime",
                aj: "lastMonthTime",
                ak: "lastWeekTime",
                al: "isMonthlyCard",
                am: "isWeekCard",
                an: "payAddZs",
                ao: "monthObj",
                ap: "weekObj",
                aq: "allKey",
                ar: "xfjl",
                as: "dayString"
            };
            this.parseObj = {};
            this.saveKey = "PayDataSave";
            this.curDate = null;
            this.callData = null;
            this.dayTime = 864e5;
            this.payCofList = {};
            this.sendLog = {
                20201: "120201",
                20202: "120202",
                20203: "120203",
                20204: "120204",
                20205: "120205",
                20206: "120206",
                20101: "120101",
                20102: "120102",
                20111: "120111",
                20112: "120112",
                20113: "120113",
                20121: "120121",
                20122: "120122",
                20123: "120123",
                20124: "120124",
                20131: "120131",
                20132: "120132",
                20133: "120133",
                20134: "120134",
                20141: "120141",
                20142: "120142",
                20143: "120143",
                20144: "120144",
                20145: "120145",
                20301: "120301",
                20161: "120161",
                20162: "120162",
                20021: "120021",
                20031: "120031",
                20032: "120032"
            };
        }
        t.prototype.parsePlayerData = function(t) {
            if ("" != t) {
                var e = this._archive,
                    o = JSON.parse(t);
                for (var a in o) {
                    var i = this.psw[a];
                    i && o[a] && (e[i] = o[a]);
                    "dayString" == i && console.log("PayData ----------------- 云端更新的日期" + o[a]);
                }
                this.checkNewDay();
            }
        };
        t.prototype.getPlayerData = function() {
            var t = this._archive;
            for (var e in this.psw) {
                var o = this.psw[e];
                this.parseObj[e] = t[o];
            }
            return JSON.stringify(this.parseObj);
        };
        t.prototype.initAccount = function(t) {
            var e = this.saveKey,
                o = cc.sys.localStorage.getItem(e);
            this.saveKey = "PayDataSave" + t;
            if (o) {
                cc.sys.localStorage.setItem(this.saveKey, o);
                cc.sys.localStorage.setItem(e, "");
            }
            this._archive = new c(this.saveKey, !0);
            this.checkLoadData();
            this.checkNewDay();
        };
        t.prototype.checkNewDay = function() {
            var t = this.getDate();
            if (this._archive.dayString != t) {
                this._archive.dayString = t;
                this._archive.lastMonthTime = "1";
                this._archive.lastWeekTime = "1";
                this._archive.shopBuy = {};
                this._archive.saveData();
            }
        };
        t.prototype.logData = function() {
            console.log("PayData ----------------- ", this._archive);
        };
        t.prototype.newDay = function() {
            this._archive.lastMonthTime = "1";
            this._archive.lastWeekTime = "1";
            this._archive.dayString = "1";
            this._archive.saveData();
        };
        t.prototype.getDate = function() {
            this.curDate || (this.curDate = new Date(s.default.serverTime));
            return this.curDate.getFullYear() + "-" + this.curDate.getMonth() + "-" + this.curDate.getDate();
        };
        t.prototype.isOverKey = function(t) {
            return this._archive.allKey[t] || !1;
        };
        t.prototype.setOverKey = function(t, e) {
            this._archive.allKey[t] = e;
            this._archive.saveData();
        };
        t.prototype.checkLoadData = function() {
            var t = this;
            this._archive.map1 = !1;
            this._archive.map1 ||
                this.loadCallBack(function(e) {
                    t.parsePlayerData(e);
                    t._archive.saveData();
                });
        };
        t.prototype.loadCallBack = function(t) {
            var e = this;
            if (window.PlayerData && window.PlayerData.canLoadData) {
                window.PlayerData.checkOverCount++;
                t && t(PlayerData.getParsePayString());
            } else
                setTimeout(function() {
                    e.loadCallBack(t);
                }, 100);
        };
        t.prototype.payCall = function(t, e) {
            var o = this;
            if (!this.callData) {
                this.callData = e;
                setTimeout(function() {
                    o.callData && o.callData(!0);
                    o.callData = null;
                }, 1e3);
            }
        };
        t.prototype.getWeekIsGetReward = function(t) {
            return !!this._archive.weekObj[t];
        };
        t.prototype.getMonthIsGetReward = function(t) {
            return !!this._archive.monthObj[t];
        };
        t.prototype.getTodayMouth = function() {
            return this._archive.lastMonthTime != this.getDateStr();
        };
        t.prototype.getTodayWeek = function() {
            return this._archive.lastWeekTime != this.getDateStr();
        };
        t.prototype.setWeekIsGetReward = function(t) {
            if (!this._archive.weekObj[t]) {
                this._archive.lastWeekTime = this.getDateStr();
                this._archive.weekCardTime--;
                if (this._archive.weekCardTime <= 0) {
                    this._archive.weekCardTime = 0;
                    this._archive.lastWeekTime = "";
                }
            }
            this._archive.weekObj[t] = !0;
            this._archive.saveData();
        };
        t.prototype.setMonthIsGetReward = function(t) {
            if (!this._archive.monthObj[t]) {
                this._archive.lastMonthTime = this.getDateStr();
                this._archive.monthlyCardTime--;
                if (this._archive.monthlyCardTime <= 0) {
                    this._archive.monthlyCardTime = 0;
                    this._archive.lastMonthTime = "";
                }
            }
            this._archive.monthObj[t] = !0;
            this._archive.saveData();
        };
        t.prototype.getDateStr = function() {
            var t = new Date(s.default.serverTime);
            return t.getFullYear() + "-" + t.getMonth() + "-" + t.getDate();
        };
        t.prototype.reduceMouth = function() {
            var t = 1 * this.dayTime;
            this._archive.isMonthlyCard && (this._archive.monthlyCardTime -= t);
            this._archive.saveData();
        };
        t.prototype.add4HDataCost = function(t, e) {
            EVUIEffView.emit(EVUIEffView.moveCoin, t, 3, e, "0");
        };
        t.prototype.setCostMul20 = function(t) {
            if (t > 1) {
                var e = this.getMulTime20();
                this._archive.mulAd2AddPro > 1 ?
                    (this._archive.mulAd2Time += e) :
                    (this._archive.mulAd2Time = Date.now() + e);
            } else this._archive.mulAd2Time = 0;
            this._archive.mulAd2AddPro = t;
            this._archive.saveData();
        };
        t.prototype.setCostMul5 = function(t) {
            if (t > 1) {
                var e = this.getMulTime5();
                this._archive.mulAd3AddPro > 1 ?
                    (this._archive.mulAd3Time += e) :
                    (this._archive.mulAd3Time = Date.now() + e);
            } else this._archive.mulAd3Time = 0;
            this._archive.mulAd3AddPro = t;
            this._archive.saveData();
        };
        t.prototype.getMul5Time = function() {
            return this._archive.mulAd3Time;
        };
        t.prototype.getMul20Time = function() {
            return this._archive.mulAd2Time;
        };
        t.prototype.getMulTime5 = function() {
            return 3e5;
        };
        t.prototype.getMulTime20 = function() {
            return 12e5;
        };
        t.prototype.getMulAdd2Pro = function() {
            return this._archive.mulAd2AddPro;
        };
        t.prototype.getMulAdd5Pro = function() {
            return this._archive.mulAd3AddPro;
        };
        t.prototype.isBuyShopData = function(t) {
            return this._archive.shopBuy[t];
        };
        t.prototype.setShopMul = function(t) {
            this._archive.mulAdAddPro = t;
            this._archive.saveData();
        };
        t.prototype.addPropData = function(t, e, o, a) {
            void 0 === a && (a = "0");
            if (t == r.RewardResKind.zhuanShi) {
                var i = "" + e;
                "" != i && EVUIEffView.emit(EVUIEffView.moveZhuanShi, o, 2, i + "", a);
            }
        };
        t.prototype.addLog = function(t, e, o, a, i, n) {
            console.log("addlog", s.default.token);
            if (s.default.token) {
                var c = {
                    token: s.default.token,
                    itemId: t,
                    itemNum: 1,
                    itemCost: e,
                    itemType: o,
                    rewardArr: JSON.stringify(a),
                    balance: GameDataValue.getPropCount(r.PropKind.zhuanshi),
                    msgid: i,
                    detail: n,
                    gameid: s.default.gameid,
                    channel: s.default.channel
                };
                console.log("addLog ----------------- params", JSON.stringify(c));
                PlayerData.requestJson(
                    "https://xmtx.yonyow.com/api.user.v2/reportUserLog",
                    function(t) {
                        0 != t.code ?
                            console.log("添加日志成功:", JSON.stringify(t)) :
                            console.log("添加日志失败:", t.msg);
                    },
                    this,
                    "POST",
                    function() {},
                    c,
                    "application/json"
                );
            }
        };
        t.prototype.getDay = function() {
            var t = new Date(s.default.serverTime);
            return (
                t.getFullYear() +
                "-" +
                t.getMonth() +
                "-" +
                t.getDate() +
                "-" +
                t.getHours() +
                "-" +
                t.getMinutes() +
                "-" +
                t.getMilliseconds()
            );
        };
        t.prototype.addAddPropData = function() {};
        t.prototype.getMouthMaxCount = function(t) {
            for (var e = t, o = 0; o < t; o++) {
                var a = o;
                if (!this.getMonthIsGetReward(a)) return a;
            }
            return e;
        };
        t.prototype.getWeekMaxCount = function(t) {
            for (var e = t, o = 0; o < t; o++) {
                var a = o;
                if (!this.getWeekIsGetReward(a)) return a;
            }
            return e;
        };
        t.prototype.getCanMouth = function() {
            return this._archive.isMonthlyCard;
        };
        t.prototype.getCanWeak = function() {
            return this._archive.isWeekCard;
        };
        t.prototype.clearLastTime = function() {
            this._archive.lastMonthTime = "";
            this._archive.lastWeekTime = "";
            this._archive.saveData();
        };
        t.prototype.getMouthCount = function() {
            var t = this.getMouthTime();
            if (t > 0) return t;
            if (this._archive.isMonthlyCard) {
                this._archive.monthlyCardTime = 0;
                this._archive.lastMonthTime = "";
                this._archive.monthObj = {};
                this._archive.isMonthlyCard = !1;
                this._archive.saveData();
            }
            return t;
        };
        t.prototype.openMouth = function() {
            if (this._archive.isMonthlyCard) this._archive.monthlyCardTime = 30;
            else {
                this._archive.monthlyCardTime <= 0 ?
                    (this._archive.monthlyCardTime = 30) :
                    (this._archive.monthlyCardTime += 30);
                this._archive.isMonthlyCard = !0;
            }
            this._archive.saveData();
        };
        t.prototype.openWeak = function() {
            if (this._archive.isWeekCard) this._archive.weekCardTime = 7;
            else {
                this._archive.weekCardTime < 0 ? (this._archive.weekCardTime = 7) : (this._archive.weekCardTime += 7);
                this._archive.isWeekCard = !0;
            }
            this._archive.saveData();
        };
        t.prototype.getWeakCount = function() {
            var t = this.getWeakTime();
            if (t > 0) return t;
            if (this._archive.isWeekCard) {
                this._archive.weekObj = {};
                this._archive.weekCardTime = 0;
                this._archive.lastWeekTime = "";
                this._archive.isWeekCard = !1;
                this._archive.saveData();
            }
            return t;
        };
        t.prototype.getMouthTime = function() {
            return this._archive.monthlyCardTime || 0;
        };
        t.prototype.getWeakTime = function() {
            return this._archive.weekCardTime || 0;
        };
        t.prototype.getProMul = function() {
            return this._archive.mulAdAddPro;
        };
        t.prototype.getPayQualityEquip = function(t, e, o, a) {
            var i = t + "_" + e + "_" + o;
            if (!this._archive.shopBuy[i]) {
                var n = CacheDataManager.getRandMostUp(a + "");
                n && (this._archive.shopBuy[i] = n);
                this._archive.saveData();
            }
            return this._archive.shopBuy[i];
        };
        t.prototype.setIsBuy = function(t, e) {
            this._archive.isBuyData[t] = e;
            this._archive.saveData();
        };
        t.prototype.isBuyData = function(t) {
            return this._archive.isBuyData[t];
        };
        t.prototype.addPropZs = function(t, e) {
            void 0 === e && (e = 700);
            this._archive.payAddZs += t;
            this._archive.payAddZs = Math.min(e, this._archive.payAddZs);
            this._archive.saveData();
        };
        t.prototype.getProZsCount = function() {
            return this._archive.payAddZs;
        };
        t.prototype.resetPayCof = function(t) {
            var e = this;

            cc.resources.load('payData', (err, json) => {
                var o = json.json;
                if (1 == o.code && "success" == o.message) {
                    var a = o.result;
                    s.default.productList = a;
                    if (a && a.length > 0) {
                        var i = {};
                        for (var n in a) {
                            e.payCofList[a[n].product_id] = a[n].pname;
                            a[n] && a[n].product_id && (i[a[n].product_id] = a[n]);
                        }
                        for (var n in t.shop)
                            t.shop[n] &&
                            i[t.shop[n].product_id] &&
                            (t.shop[n].cash = i[t.shop[n].product_id].price);
                    }
                }

            })
        };
        t.prototype.checkPayCost = function() {
            return SdkManager.haveCallBack();
        };
        t.prototype.udpateCall = function() {
            SdkManager.udpateCall();
        };
        t.prototype.checkSendKey = function(t) {
            var e = "" + this.sendLog[t] || "";
            "" != e && QReport.send(e);
        };
        t.prototype.addPayData = function(t, e, o, a) {
            console.log("PayData -----------------pay id  " + t, e);
            if (s.default.isWk) {
                var i = CacheDataManager.getShopDataCof().shop;
                if (i && i[t] && i[t].product_id) {
                    console.log("商品名称", JSON.stringify(this.payCofList), i[t].product_id);
                    this.checkSendKey(t + "");
                    SdkManager.addPayData(i[t].product_id, this.payCofList[i[t].product_id], e, o, a);
                } else console.log("支付", "获取商品id失败", JSON.stringify(i[t]));
            } else o(!0);
        };
        return t;
    })())();
window.PayData = p;
o.default = p;